#pragma once
#include <d3d9.h>
#include <d3dx9.h>
#include <utility>

#include "../frame/frame.h"
#include "../basiclib/Common.h"
#include "../basiclib/texture.h"

#include <vector>
using std::vector;

class Tgo2DEntity;

class Sprite
{
public:
							Sprite();
							~Sprite();
	void					ReleaseSprites();
	void					OnInit();
	void					Render();
	int						AddSprite( Tgo2DEntity* entity );
	std::pair< int, int >	AddSpritesList( vector< Tgo2DEntity* > entity );
	void					RemoveSprite( int i );
	void					RemoveSpriteList( int i, int j );

	Tgo2DEntity*			GetSprite( int i );
	vector< Tgo2DEntity* >&	GetSpriteList() { return mEntities; }
	void					SetSpriteList( vector< Tgo2DEntity* > entities ) { mEntities = entities; }
private:
	ID3DXSprite*			mSprite;
	vector< Tgo2DEntity* >	mEntities;
};

class Tgo2DEntity
{
public:
							Tgo2DEntity( D3DXVECTOR3 pos, float angle );
							~Tgo2DEntity();

	D3DXMATRIX				GetTransform();
	float					GetAngle();
	D3DXVECTOR3				GetPos();
	D3DXVECTOR3				GetCenter();
	LPDIRECT3DTEXTURE9		GetTexture();
	RECT					GetTexCoord();
	UINT					GetWidth();
	UINT					GetHeight();
	bool					IsVisible();
	bool					IsSubTexture();

	void					SetPos( D3DXVECTOR3 pos );
	void					SetPos( D3DXVECTOR2 pos );
	void					SetCenter( D3DXVECTOR3 center );
	void					SetAngle( float angle );
	void					SetTexture( string texKey );
	void					SetTexCoord( RECT texCoord );
	void					SetState( bool visible );
private:
	D3DXVECTOR3 			mCenter;
	D3DXVECTOR3				mPos;
	float					mAngle;
	Texture*				mTex;

	RECT					mTexCoord;

	bool					mIsVisible;
	bool					mIsSubTexture;
};